<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body>
  <div id="app">
    {{ doubleNum }}
    <button @click="changeNum">点击改变doubleNum</button>
    <hr>
  </div>
  <script src="./vue.js"></script>
  
  <script>
    //   "  123435.4a567"
    const vm = new Vue({
      el: '#app',
      data: {
        num: 2,
      },
      computed: {
        doubleNum:{
          get(){
            return this.num*2;
          },
          set(val){
            console.log('设置值', val);
            this.num = val/2;
          }
        }
      },
      methods: {
        changeNum(){
          this.doubleNum = 8;
        }
      }
    })
    console.log(vm)
  
  </script>
</body>
</html>